<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>富文本编辑器</title>
</head>
<body>
    <!-- <textarea></textarea> -->
    <button onclick="boldStyle()">加粗</button><button onclick="italicStyle()">倾斜</button><button onclick="redStyle()">红色文字</button>
    <div contenteditable style="border:1px solid #dedede; width: 500px; min-height:300px;">
        <img src="./src/assects/images/logo.png" alt=""/>

    </div>
    <script>
        var boldStyle = function(){
            document.execCommand('Bold');
        }
        var italicStyle = function(){
            document.execCommand('italic');
        }
        var redStyle = function(){
            document.execCommand('foreColor',null,'red');
        }
    </script>
</body>
</html>